package crm

import (
	"git.mycaigou.com/gfyx/micro-gfyx-oppty-service/infrastructure/repository/clue/crm/contract"
	"git.mycaigou.com/gfyx/micro-gfyx-oppty-service/infrastructure/repository/clue/crm/neocrm"
)

const (
	NeoCrmCode = "neocrm" //销售易的crm系统
)

type allCrmSystem struct {
	cache map[string]contract.ThirdCrmIface
}

var AllCrm allCrmSystem

func init() {
	//todo 后续对接了其他的crm系统，需要在此处做初始化，保存到全局map中
	AllCrm.cache = make(map[string]contract.ThirdCrmIface)
	AllCrm.cache[NeoCrmCode] = neocrm.NewNeoCrmRepository()
}

func (crm *allCrmSystem) GetCRMBySystemName(systemName string) (bool, contract.ThirdCrmIface) {
	thirdCrm, ok := crm.cache[systemName]
	return ok, thirdCrm
}
